#pragma GCC optimize(2)
#include <iostream>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <unordered_set>
#include <stack>
#include <bitset>
#define F first
#define S second
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
int gcd(int a,int b)
{
	return b==0 ? a : gcd(b,a%b);
}
void solve()
{
	int n;
	cin>>n;
	vector<int> a(n+5,0);
	for(int i=1;i<=n;i++) cin>>a[i];
	int sum=1;
	int b=1;
	int c=0;
	int f=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==1)
		{
			sum++;
			b++;
		}
		else if(a[i]==0)
		{
			if(sum>1) sum--,c++;
			else
			{
				sum++;
				b++;
			}
		}
		else
		{
			sum--;
			if(sum==0 && c>0)
			{
				sum+=2;
				c--;
				b++;
			}
			else if(sum==0 && c==0)
			{
				f=1;
				break;
			}
		}
	}
	if(f) cout<<-1<<'\n';
	else
	{
		int num=gcd(b,sum);
		cout<<b/num<<' '<<sum/num<<'\n';
	}
}
int main()
{
	IOS;
	int T=1;
	cin>>T;

	while(T--)
	{
		solve();
	}

	return 0;
}

